package com.company.笔试.最长无重复子数组.最长无重复子串;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * @Classname Solution
 * @Description TODO
 * @Date 2021/8/15 18:41
 * @Created by ylr
 */
public class Solution {
    public static void main(String[] args) {
        System.out.println(Solution.Main1("abcabcbb"));
    }

    public static int Main1(String s){
        Queue<Character> characterQueue = new LinkedList<>();
        int res = 0;
        for (char c : s.toCharArray()) {

            if (characterQueue.contains(c)) {
                characterQueue.poll();
            }
            characterQueue.add(c);
            res = Math.max(res,characterQueue.size());
        }
        return res;
    }

    public static void main21(String[] args){

        Scanner in = new Scanner(System.in);

        String xstr = in.nextLine();
        int xlen = xstr.length();
        String[] str = xstr.split(" ");
        HashMap map  = new HashMap<String,Integer>();
        map.put("1",0);
        map.put("2",0);
        map.put("3",0);
        for(String i : str){
            map.put(i,(int)map.get(i)+1);
        }

        for(int j=1;j<=3;j++){
            int num =-1;
            while(map.containsKey(j)&&num!=0){
                num = (int)map.get(j);
                System.out.print(j+" ");
                map.put(j,--num);

            }
        }
    }

}
